﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Collections;

namespace Consultator
{
    class Connection 
    {
        private String connectionString = ("Data Source=ERNESTAS-PC\\SQLEXPRESS;Initial Catalog=ANSWER_QUESTIONS;Integrated Security=True");

        public void GetAllInfo(int id, ArrayList RequestList, ArrayList YesList, ArrayList NoList) 
        {
            using (var connection = new SqlConnection(connectionString))
            {
                connection.Open();
                //sql injection
                String query = "SELECT * FROM Table_1 WHERE id = " + id;
                using (var command = new SqlCommand(query, connection))
                {

                    var reader = command.ExecuteReader();
                   // var RequestList = new ArrayList();
                   // var YesList = new ArrayList();
                   // var NoList = new ArrayList();
                    while (reader.Read()) 
                    {
                        String request = reader.GetString(1);
                        String yes = reader.GetString(2);
                        String no = reader.GetString(3);
                        RequestList.Add(request);
                        YesList.Add(yes);
                        NoList.Add(no);
                    }
                    connection.Close();
                    reader.Close();
                    //return list;
                }

            }
        }
    }
}
